<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>添加战队</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link rel="stylesheet" href="css/ydui.css?rev=@@hash" />
    <link rel="stylesheet" href="css/demo.css" />
    <script src="js/ydui.flexible.js"></script>
    <style>
        .cell-left {
            width: 20%
        }
    </style>
</head>

<body>
    <section class="g-flexview" id="app" v-cloak>
        <sync-loader v-if="loading" :color="color"></sync-loader>
        <header class="m-navbar">
            <a href="javascript:history.back();" class="navbar-item">
                <i class="back-ico"></i>
            </a>
            <div class="navbar-center">
                <span class="navbar-title">添加战队</span>
            </div>
        </header>

        <section class="g-scrollview" v-if="!loading">
            <div class="m-cell demo-small-pitch">
                <div class="cell-item">
                    <div class="cell-left">战队ID</div>
                    <div class="cell-right">
                        <input type="text" id="gameId" v-model="gameId" class="cell-input" value="" placeholder="支持靓号" autocomplete="off" />
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left">战队昵称</div>
                    <div class="cell-right">
                        <input type="text" id="gameName" v-model="gameName" class="cell-input" value="" placeholder="支持靓号" autocomplete="off" />
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left">战队地址</div>
                    <div class="cell-right cell-arrow">
                        <input type="text" id="gameaddress" v-model="gameaddress" @click="addcity" readonly class="cell-input" placeholder="请选择网吧地址" />
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left">战队图片</div>
                    <div class="cell-right">
                        <a href="javascript:;" class="btn btn-primary">上传图片</a>
                    </div>
                </div>
                <div class="m-celltitle">战队简介</div>
                <div class="m-cell">
                    <div class="cell-item">
                        <div class="cell-right">
                            <textarea class="cell-textarea" v-model="gameReferral" placeholder="请输入战队简介"></textarea>
                        </div>
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left">队长</div>
                    <div class="cell-right">
                        <input type="text" class="cell-input" value="" v-model="CaptainPhone" placeholder="输入管理员手机号" autocomplete="off" />
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left">鸡蛋数</div>
                    <div class="cell-right">
                        <input type="text" class="cell-input" value="" v-model="eggNum" style="width:30%" placeholder="默认展示当前鸡蛋数" autocomplete="off" />
                        <a href="javascript:;" class="btn btn-primary add_egg margin_r5" @click="eggNuma" id="J_Confirm">加鸡蛋</a>
                        <a href="javascript:;" class="btn btn-primary add_egg" @click="eggNumj" id="J_Confirm_subtract">减鸡蛋</a>
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left">邀请码</div>
                    <div class="cell-right">
                        <input type="text" class="cell-input" v-model="invitationCode" value="" placeholder="请输入邀请码" autocomplete="off" />
                    </div>
                </div>
                <div class="cell-item">
                    <div class="cell-left"></div>
                    <div class="cell_right_bz">注：按对员参与赛场的利润给战队队长结算</div>
                </div>
                <div class="cell-item">
                    <div class="cell-left"></div>
                    <div class="cell-right">
                        <input type="text" class="cell-input" value="" v-model="promote" placeholder="请输入提升百分比" autocomplete="off" />
                    </div>
                </div>
            </div>
            <div class="m-button">
                <button type="button" id="saveBtn" class="btn-block btn-primary" @click="saveBtn">保存</button>
            </div>

        </section>

    </section>
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="js/ydui.js"></script>
    <script src="js/ydui.citys.js"></script>
    <script src="js/vue.min.js"></script>
    <script src="js/vue-resource.js"></script>
    <script src="js/vue-spinner-master/dist/vue-spinner.js"></script>
    <script src="js/layer/layer.js"></script>
</body>
<script>
    // $('#gameaddress').on('click ', function() {

    // });

    /* 获取头部信息 */
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return r[2];
        }
    };
    var SyncLoader = VueSpinner.SyncLoader
    var app = new Vue({
        el: '#app',
        components: {
            'SyncLoader': SyncLoader
        },
        data: {
            userRole: GetQueryString('userRole'),
            rowId: GetQueryString('rowId'),
            token: GetQueryString('token'),
            loading: true,
            color: '#FF6C00',
            gameId: '',
            gameName: '',
            gameaddress: '',
            gameReferral: '',
            CaptainPhone: '',
            eggNum: '',
            invitationCode: '',
            promote: ''
        },
        methods: {
            get: function() {
                this.$http({
                    method: "post",
                    url: "http://192.168.2.201:8080/appTeam/pubgTeamDetail",
                    data: {
                        token: this.token,
                        rowId: this.rowId,
                        userRole: this.userRole
                    },
                    emulateJSON: true
                }).then(function(res) { // 访问成功后执行
                    this.loading = false;
                    console.log(res);
                    this.details = res.data.data;
                    this.Userpic = res.data.teamPhoto;
                }, function(error) { // 访问失败执行
                    console.log(error);
                    layer.msg('接口返回失败');
                    this.loading = false;
                })
            },
            addcity: function() {
                var $address = $('#gameaddress');
                $address.citySelect();
                $address.on('click', function() {
                    $address.citySelect('open');
                });
                $address.on('done.ydui.cityselect', function(ret) {
                    /* 省：ret.provance */
                    /* 市：ret.city */
                    /* 县：ret.area */
                    $(this).val(ret.provance + ' ' + ret.city + ' ' + ret.area);
                });
            },
            eggNuma: function() {
                dialog.confirm('填写加鸡蛋数量', '<input  type="number" class="cell-input num_bor_s" value="" placeholder="请输入数量" autocomplete="off" />',
                    function() {
                        layer.msg('你点了确定');
                    });
            },
            eggNumj: function() {
                dialog.confirm('填写减鸡蛋数量', '<input  type="number" class="cell-input num_bor_s" value="" placeholder="请输入数量" autocomplete="off" />',
                    function() {
                        layer.msg('你点了确定');
                    });
            },
            saveBtn: function() {
                if (this.gameId == "" || this.gameId == null) {
                    layer.msg('请输入战队Id');
                } else if (this.gameName == "" || this.gameName == null) {
                    layer.msg('请输入战队昵称');
                } else if ($("#gameaddress").val() == "" || $("#gameaddress").val() == null) {
                    layer.msg('请输入战队地址');
                    console.log($("#gameaddress").val());
                } else if (this.gameReferral == "" || this.gameReferral == null) {
                    layer.msg('请输入战队简介');
                } else if (this.CaptainPhone == "" || this.CaptainPhone == null) {
                    layer.msg('请输入队长手机号');
                } else if (this.eggNum == "" || this.eggNum == null) {
                    layer.msg('请输入鸡蛋数');
                } else if (this.invitationCode == null || this.invitationCode == "") {
                    layer.msg('请输入邀请码');
                } else if (this.promote == "" || this.promote == null) {
                    layer.msg('请输入提升百分比');
                }
            }
        },
        mounted: function() {
            this.$nextTick(function() {
                this.get();
            })
        }
    })
</script>

</html>